package cn.work.service.impl;


import cn.work.dao.UserMapper;
import cn.work.entity.User;
import cn.work.service.CrudService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service("crudServiceImpl")
public class CrudServiceImpl implements CrudService {

   @Autowired
   private UserMapper userMapper;

    public List<User> findAllUser() {
        List<User> list=userMapper.selectAllUser();
        return list;
    }

    public void addUser(User user) {
        userMapper.insertUser(user);
    }

    public User findUserById(int id) {
        User user=userMapper.selectUserById(id);
        return user;
    }

    public void clearById(int id) {
        userMapper.deleteByPrimaryKey(id);
    }

    public void incerseUser(User user) {
        userMapper.insert(user);
    }

    public void editUser(User user) {
        userMapper.updateByPrimaryKeySelective(user);
    }


}
